package common.consts;

/**
 * Created by aceyin on 15/6/25.
 */
public enum Weekday {
    SUNDAY(1, "周日"),
    MONDAY(2, "周一"),
    TUESDAY(3, "周二"),
    WEDNESDAY(4, "周三"),
    THURSDAY(5, "周四"),
    FRIDAY(6, "周五"),
    SATURDAY(7, "周六");

    public final int val;
    public final String name;

    Weekday(int val, String name) {
        this.val = val;
        this.name = name;
    }

    public static Weekday get(int val) {
        int n = val > 7 ? (val % 7) : val;
        for (Weekday weekday : Weekday.values()) {
            if (weekday.val == n) {
                return weekday;
            }
        }
        // no possible run to here
        return SUNDAY;
    }
}
